var app = getApp();
let globalData = app.globalData;
Page({
    data: {
        url: '',
        act: 'A',
        qian_img: globalData.qian_img,
        winHeight: "", //窗口高度
        currentTab: 0, //预设当前项的值
        scrollLeft: 0, //tab标题的滚动条位置
        expertList: [{ //假数据
                name: "avatar.png",
            },
            { //假数据
                name: "avatar.png",
            },
            { //假数据
                name: "avatar.png",
            },
        ],
        // https://jzy.nuoche.la/images/build_img/A.jpg
        imgList: [
            'images/build_img/a.jpg',
            'images/build_img/a1.jpg',
            'images/build_img/b1.jpg',
            'images/build_img/b2.jpg',
            'images/build_img/c.jpg',
            'images/build_img/d.jpg'
        ],
       imgBg:''
    },
    // 滚动切换标签样式
    switchTab: function(e) {
        this.setData({
            currentTab: e.detail.current
        });
        this.checkCor();
    },
    // 点击标题切换当前页时改变样式
    swichNav: function(e) {
        var cur = e.target.dataset.current;
        if (this.data.currentTaB == cur) {
            return false;
        } else {
            this.setData({
                currentTab: cur
            })
        }
    },
    //判断当前滚动超过一屏时，设置tab标题滚动条。
    checkCor: function() {
        if (this.data.currentTab > 2) {
            this.setData({
                scrollLeft: 300
            })
        } else {
            this.setData({
                scrollLeft: 0
            })
        }
    },
    onLoad: function() {
        var that = this;
        //  高度自适应
        wx.getSystemInfo({
            success: function(res) {
                var clientHeight = res.windowHeight,
                    clientWidth = res.windowWidth,
                    rpxR = 750 / clientWidth;
                var calc = clientHeight * rpxR - 80;
                console.log(calc)
                that.setData({
                    winHeight: calc
                });
            }
        });
        this.getData();
    },
    footerTap: app.footerTap,
    getData(){
        let data={
            pid:globalData.pid
        }
        globalData.sendPost('house/building',data).then(res=>{
            if(res.status==1){
                this.setData({
                    imgList:res.data,
                    imgBg:res.building_img
                })
            }
        })
    }
})